// ******************************************************************
// * Copyright(c)  Steven Lu
// * Description   : Entity_FIN_MAP_IRA_SDO
// * CreateDate    : 2012/2/2 10:17:12
// * Creater       : CodeSmith
// * LastChangeDate: 2012/2/2 10:17:12
// * LastChanger   : 2012/2/2 10:17:12
// * Version Info  : 1.0 For ESOL
// ******************************************************************

using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Suzsoft.Smart.Data;
using ESOL.Common.Entity;

namespace ESOL.Business.Fin
{
/// <summary>
    /// FinMapIraSdo
    /// </summary>
    public partial class FinMapIraSdoBs
    {
        #region GetByID
        /// <summary>
        /// Get Entity
        /// </summary>
        /// <param name="objFinMapIraSdoEntity">Entity</param>
        /// <returns>Entity</returns>
        public static FinMapIraSdoEntity GetFinMapIraSdo(FinMapIraSdoEntity objFinMapIraSdoEntity)
        {
            return DataAccess.SelectSingle<FinMapIraSdoEntity>(objFinMapIraSdoEntity);
        }
        public static List<FinMapIraSdoEntity> GetByApplicationID(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return null;
            }
            FinMapIraSdoEntity entity = new FinMapIraSdoEntity();
            entity.ApplicationId = id;
            return DataAccess.Select<FinMapIraSdoEntity>(entity);
        }
        public static List<FinMapIraSdoEntity> GetByDeliveryOrderID(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return null;
            }
            FinMapIraSdoEntity entity = new FinMapIraSdoEntity();
            entity.DeliveryOrderId = id;
            return DataAccess.Select<FinMapIraSdoEntity>(entity);
        }
        public static List<SalesDeliveryOrderEntity> GetDeliveryOrderByApplicationID(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return null;
            }
            string sql = @"SELECT SDO.*
                            FROM FIN_BILLING_RECEIVED_APPLICATION BRA
                            INNER JOIN FIN_MAP_IRA_SDO MAP ON MAP.APPLICATION_ID = BRA.APPLICATION_ID
                            INNER JOIN SALES_DELIVERY_ORDER SDO ON MAP.DELIVERY_ORDER_ID = SDO.DELIVERY_ORDER_ID
                            WHERE BRA.APPLICATION_ID = '" + id + "'";
            return DataAccess.Select<SalesDeliveryOrderEntity>(sql);
        }
        #endregion

        #region Insert
        /// <summary>
        /// Insert Data
        /// </summary>
        /// <param name="objFinMapIraSdoEntity">Entity</param>
        /// <returns>true Insert Succeed; false Insert Fail</returns>
        public static bool InsertFinMapIraSdo(FinMapIraSdoEntity objFinMapIraSdoEntity)
        {
            return DataAccess.Insert(objFinMapIraSdoEntity);
        }

        public static bool InsertFinMapIraSdo(List<FinMapIraSdoEntity> objFinMapIraSdoEntityList)
        {
            return DataAccess.Insert(objFinMapIraSdoEntityList);
        }
        #endregion

        #region Update
        /// <summary>
        /// Update Data
        /// </summary>
        /// <param name="objFinMapIraSdoEntity">Entity</param>
        /// <returns>true Update Succeed; false Update Fail</returns>
        public static bool UpdateFinMapIraSdo(FinMapIraSdoEntity objFinMapIraSdoEntity)
        {
            return DataAccess.Update(objFinMapIraSdoEntity);
        }

        public static bool UpdateFinMapIraSdo(List<FinMapIraSdoEntity> objFinMapIraSdoEntityList)
        {
            return DataAccess.Update<FinMapIraSdoEntity>(objFinMapIraSdoEntityList);
        }
        #endregion

        #region Delete
        /// <summary>
        /// Delete Data
        /// </summary>
        /// <param name="objFinMapIraSdoEntity">Entity</param>
        /// <returns>true Delete Succeed; false Delete Fail</returns>
        public static bool DeleteFinMapIraSdo(FinMapIraSdoEntity objFinMapIraSdoEntity)
        {
            return DataAccess.Delete(objFinMapIraSdoEntity);
        }

        public static bool DeleteFinMapIraSdo(List<FinMapIraSdoEntity> objFinMapIraSdoEntityList)
        {
            return DataAccess.Delete<FinMapIraSdoEntity>(objFinMapIraSdoEntityList);
        }
        #endregion

        #region GetAll
        /// <summary>
        /// Get All Data
        /// </summary>
        /// <returns>Back All Data<returns>
        public static DataSet GetFinMapIraSdoAll()
        {
            return DataAccess.SelectAllDataSet<FinMapIraSdoEntity>();
        }
        /// <summary>
        /// Get All Data List
        /// </summary>
        /// <returns>Back All Data List<returns>
        public static List<FinMapIraSdoEntity> GetFinMapIraSdoAllList()
        {
            return DataAccess.SelectAll<FinMapIraSdoEntity>();
        }
        #endregion
	}
	
	
}	

